package com.ruoyi.wechat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.CampUser;
import com.ruoyi.wechat.service.ICampUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 微信用户管理Controller
 * 
 * @author jiang
 * @date 2024-09-30
 */
@RestController
@RequestMapping("/wechat/campUser")
public class CampUserController extends BaseController
{
    @Autowired
    private ICampUserService campUserService;
    /**
     * 查询所有用户信息
     */
    @PreAuthorize("@ss.hasPermi('wechat:campUser:list')")
    @GetMapping("/all")
    public TableDataInfo all(CampUser campUser)
    {
        List<CampUser> list = campUserService.selectCampUserList(campUser);
        return getDataTable(list);
    }
    /**
     * 查询微信用户管理列表
     */
    @PreAuthorize("@ss.hasPermi('wechat:campUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(CampUser campUser)
    {
        startPage();
        List<CampUser> list = campUserService.selectCampUserList(campUser);
        return getDataTable(list);
    }

    /**
     * 导出微信用户管理列表
     */
    @PreAuthorize("@ss.hasPermi('wechat:campUser:export')")
    @Log(title = "微信用户管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CampUser campUser)
    {
        List<CampUser> list = campUserService.selectCampUserList(campUser);
        ExcelUtil<CampUser> util = new ExcelUtil<CampUser>(CampUser.class);
        util.exportExcel(response, list, "微信用户管理数据");
    }

    /**
     * 获取微信用户管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('wechat:campUser:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") String userId)
    {
        return success(campUserService.selectCampUserByUserId(userId));
    }

    /**
     * 新增微信用户管理
     */
    @PreAuthorize("@ss.hasPermi('wechat:campUser:add')")
    @Log(title = "微信用户管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CampUser campUser)
    {
        return toAjax(campUserService.insertCampUser(campUser));
    }

    /**
     * 修改微信用户管理
     */
    @PreAuthorize("@ss.hasPermi('wechat:campUser:edit')")
    @Log(title = "微信用户管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CampUser campUser)
    {
        return toAjax(campUserService.updateCampUser(campUser));
    }

    /**
     * 删除微信用户管理
     */
    @PreAuthorize("@ss.hasPermi('wechat:campUser:remove')")
    @Log(title = "微信用户管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable String[] userIds)
    {
        return toAjax(campUserService.deleteCampUserByUserIds(userIds));
    }
}
